package com.test.selector_demo;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.Date;

public class Client {
	public static void main(String[] args)  {
		try {
			for (int j = 9000; j < 9002; j++) {
				Socket socket = new Socket("localhost", j);
				//SocketChannel sc = SocketChannel.open(i);
			//	sc.configureBlocking(false);
				
				DataOutputStream os = new DataOutputStream(socket.getOutputStream());
				DataInputStream is = new DataInputStream(socket.getInputStream());

				os.writeUTF("" + new Date().toString());
				String receiveMsg = is.readUTF();
				System.out.println("[client] 收到消息" + receiveMsg);
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
